<template>
  <div class="con">
    <div class="zhong">
      <el-carousel height="18vw">
        <el-carousel-item v-for="item in lunbo" :key="item.id">
          <img
            :src="item.imgUrl"
            style="width: 100%;height: 100%;"
            @click="linkLunbo(item)"
          />
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="div">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item class="dangqian">文档</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="navbox">
        <span
          v-for="(item, index) in types"
          :key="item.id"
          @click="handleLeft(index)"
          >{{ item.label }}</span
        >
      </div>
      <div
        class="navsec"
        v-for="(item, index) in types"
        :id="'id' + index"
        :key="item.id"
      >
        <div class="secbox">
          <div class="name">{{ item.label }}</div>
          <div class="spans">
            <span
              v-for="items in item.children"
              :key="items.id"
              @click="link(items.id)"
              >{{ items.label }}</span
            >
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      types: [],
      lunbo: []
    };
  },
  //注册组件
  components: {},
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.isinput();
    this.gettypes();
    this.getlunbo();
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  //计算属性
  computed: {},
  //方法
  methods: {
    gettypes() {
      this.$postRequest("/api/trotocol/getTrotocolClassList", {
        status: 1
      }).then(res => {
        this.types = res.data;
      });
    },
    getlunbo() {
      this.$postRequest("/api/cms/slide/list", {
        type: "3"
      }).then(res => {
        this.lunbo = res.data;
      });
    },
    linkLunbo(item) {
      if (item.mode == 0) {
        this.$router.push({ name: "detail", query: { id: item.goodsId } });
      } else if (item.mode == 1) {
        window.location.href = item.linkUrl;
      }
    },
    isinput() {
      this.$store.commit("setDValue", false);
    },
    handleLeft(index) {
      this.$el.querySelector(`#id${index}`).scrollIntoView({
        behavior: "smooth", // 平滑过渡
        block: "start" // 上边框与视窗顶部平齐。默认值
      });
    },
    link(id) {
      this.$router.push({ name: "documentitem", query: { id: id } });
    }
  }
};
</script>
<style scoped lang="scss">
.con {
  background-color: #f9f9f9;
  .img {
    width: 100%;
  }
  .div {
    width: 1400px;
    margin: auto;
    /deep/ .el-breadcrumb {
      height: 48px;
      font-size: 14px;
      line-height: 48px;
      .el-breadcrumb__inner {
        color: #999;
        font-weight: 500;
      }
      .dangqian .el-breadcrumb__inner {
        color: #1a69e0;
      }
    }
    .navbox {
      max-width: 1400px;
      background: #fff;
      border: 1px solid #eee;
      padding: 24px 0 0px 0;
      margin: 0 auto 20px;
      // #eee
      span {
        font-size: 16px;
        cursor: pointer;
        display: inline-block;
        border: 1px solid transparent;
        padding: 7px 15px;
        margin: 0 20px 10px 20px;
        transition: 0.2s;
      }
      span:last-child {
        margin-right: 0;
      }
      span:hover {
        border: 1px solid #1a69e0;
        color: #1a69e0;
        background: #f3f7fd;
      }
    }
    .navsec {
      background: #fff;
      max-width: 1400px;
      padding: 20px;
      margin: 0 auto;
      .secbox {
        margin: 0 auto 20px auto;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid #e5e5e5;
        .name {
          font-weight: bold;
          font-size: 16px;
          width: 150px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .spans {
          color: #666;
          font-size: 14px;
          width: calc(100% - 150px);
          span {
            cursor: pointer;
            display: inline-block;
            margin-right: 30px;
            margin-bottom: 20px;
          }
          span:hover {
            color: #1a69e0;
          }
        }
      }
      .secbox:last-child {
        margin-bottom: 0;
      }
    }
  }
}
</style>